using Microsoft.AspNetCore.Authorization;

using WXWorkSvc.Common.Extensions;
using WXWorkSvc.Common.Models;

namespace WXWorkSvc.Third.Areas.D.Pages.User;
public class IndexModel : PageModel
{
    public List<TUser> Items { get; set; } = default!;
    public TUser Item { get; set; } = default!;
    public async Task OnGet([FromServices] WXDbContext db, [FromServices] WXWork3rdConfig config, [FromServices] IRole role)
    {

        Items = await db.Users.Where(ii => ii.SuiteId == config.SuiteId && ii.CorpId == User.GetCorpId()).ToListAsync();

        foreach (var item in Items)
        {
            item.RoleNames = role.GetRoleNames(item.Roles);
        }
    }
}
